#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab

from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division

from random import randint, getrandbits

import unittest

import pelib.utils.exceptions
import pelib.utils.logging
import pelib.rule
import pelib.parsing.drivers.regexparser
import pelib.parsing.parseengine
import pelib.condition
import pelib.resolver.resolver
import pelib.ruletable
import pelib.persistence.persistenceengine
#import pelib.persistence.backends.django.django
#import pelib.persistence.backends.django.ruletablemodel
#import pelib.persistence.backends.django.rulemodel



_collectionOperators= ["in"]
_logicalOperators = ["&&", "||"]
_rangeOperators = ["[]", "{}"]
_comparisonOperators = ["=", "!=", ">", "<", ">=", "<="]

def createSimpleCompCondition(op=None):
    if op:
        return pelib.condition.Condition(
                randint(0, 100),
                randint(0, 100),
                op,
                bool(getrandbits(1)))
    return pelib.condition.Condition(
            randint(0, 100),
            randint(0, 100),
            _comparisonOperators[randint(0, len(_comparisonOperators)-1)],
            bool(getrandbits(1)))


class PETests(unittest.TestCase):

    def test_ComparisonOperators(self):
        for op in _comparisonOperators:
            a = createSimpleCompCondition(op)
            print ("Condition:", a.dump(), " result:", a.evaluate(None, None))


if __name__ == '__main__':
    unittest.main()
